package com.euond.permission.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.euond.common.core.service.impl.BaseServiceImpl;
import com.euond.permission.entities.ResourcePermission;
import com.euond.permission.mapper.ResourcePermissionMapper;
import com.euond.permission.service.ResourcePermissionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by user on 2017/11/9.
 */
@Service
public class ResourcePermissionServiceImpl extends BaseServiceImpl<ResourcePermissionMapper,ResourcePermission> implements ResourcePermissionService {
    /**
     * 根据资源ID查询权限值
     * @param resourceId
     * @return
     */
    public List<ResourcePermission> findResourcePermissionByResourceId(long resourceId){
        EntityWrapper entityWrapper=new EntityWrapper<ResourcePermission>();
        entityWrapper.eq("resource_id",resourceId);
        return selectList(entityWrapper);
    }

    /**
     * 按资源ID删除权限值
     * @param resourceId
     * @return
     */
    public void deleteResourcePermissionByResourceId(Long resourceId){
        EntityWrapper entityWrapper=new EntityWrapper<ResourcePermission>();
        entityWrapper.eq("resource_id",resourceId);
        delete(entityWrapper);
    }
}